﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary
{
    /// <summary>
    /// Represents an enumeration of iso units.
    /// </summary>
    public enum SIPrefix
    {
        /// <summary>
        /// Yotta = 10^24
        /// </summary>
        Yotta = 24,
        /// <summary>
        /// Zetta = 10^21
        /// </summary>
        Zetta = 21,
        /// <summary>
        /// Exa = 10^18
        /// </summary>
        Exa = 18,
        /// <summary>
        /// Peta = 10^15
        /// </summary>
        Peta = 15,
        /// <summary>
        /// Tera = 10^12
        /// </summary>
        Tera = 12,
        /// <summary>
        /// Giga = 10^9
        /// </summary>
        Giga = 9,
        /// <summary>
        /// Mega = 10^6
        /// </summary>
        Mega = 6,
        /// <summary>
        /// Kilo = 10^3
        /// </summary>
        Kilo = 3,
        /// <summary>
        /// Hecto = 10^2
        /// </summary>
        Hecto = 2,
        /// <summary>
        /// Deca = 10^1
        /// </summary>
        Deca = 1,
        /// <summary>
        /// Normal = 10^0
        /// </summary>
        Normal = 0,
        /// <summary>
        /// Deci = 10^-1
        /// </summary>
        Deci = -1,
        /// <summary>
        /// Cent = 10^-2
        /// </summary>
        Cent = -2,
        /// <summary>
        /// Milli = 10^-3
        /// </summary>
        Milli = -3,
        /// <summary>
        /// Micro = 10^-6
        /// </summary>
        Micro = -6,
        /// <summary>
        /// Nano = 10^-9
        /// </summary>
        Nano = -9,
        /// <summary>
        /// Pico = 10^-12
        /// </summary>
        Pico = -12,
        /// <summary>
        /// Femto = 10^-15
        /// </summary>
        Femto = -15,
        /// <summary>
        /// Atto = 10^-18
        /// </summary>
        Atto = -18,
        /// <summary>
        /// Zepto = 10^-21
        /// </summary>
        Zepto = -21,
        /// <summary>
        /// Yocto = 10^-24
        /// </summary>
        Yocto = -24
    }

    /// <summary>
    /// The static UnitConversion class provides methods to convert a number from one
    /// unit to another.
    /// </summary>
    [Serializable]
    public static class UnitConversion
    {
        /// <summary>
        /// Converts a number from a specified unit to another unit.
        /// </summary>
        /// <param name="sourceUnit">The unit of the specified number.</param>
        /// <param name="destinationUnit">The destination unit of the conversion.</param>
        /// <param name="value">The value.</param>
        /// <returns>The converted number which was convert to the new unit.</returns>
        public static double ConvertUnit(SIPrefix sourceUnit, SIPrefix destinationUnit, double value)
        {
            int power = sourceUnit - destinationUnit;

            return value * Math.Pow(10, power);
        }
    }
}